package org.millioncall.yueyoga.admin.export;

import java.util.List;

import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.millioncall.yueyoga.admin.model.TinyOrderModel;

public class TinyOrderExportTemplate extends AbstractExcelExportTemplate {
	private List<TinyOrderModel> records;
	String[] titles = new String[] { "购买人", "购买产品名称", "购买金额", "购买时间", "负责人"};
	public TinyOrderExportTemplate(List<TinyOrderModel> records) {
		this.records = records;
	}

	@Override
	public String[] getSheetNames() {
		return new String[] { "购买记录信息表" };
	}

	@Override
	public String[][] getTitles() {
		return new String[][] { titles };
	}

	@Override
	protected void buildBody(int sheetIndex) {
		Sheet sheet = getSheet(sheetIndex);
		int startIndex = this.getBodyStartIndex(sheetIndex);
		for (int i = 0; i < this.records.size(); i++) {
			TinyOrderModel record = this.records.get(i);
			Row row = sheet.createRow(i + startIndex);
			row.setHeight((short) 300);
			int index = 0;
			createStyledCell(row, index++, record.getBuyerName()==null?"":record.getBuyerName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getProductName()==null?"":record.getProductName().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getMoney()==null?"":record.getMoney().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getBuyTime()==null?"":record.getBuyTime().toString(), this.bodyRowStyle);
			createStyledCell(row, index++, record.getOfficerName()==null?"":record.getOfficerName().toString(), this.bodyRowStyle);
		}
	}

	@Override
	public String[] getCaptions() {
		return new String[] { "购买记录信息表" };
	}
}
